package com.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.admin.filter.aop.annotation.LogAnnotation;
import com.admin.entity.SysLog;
import com.admin.service.LogService;
import com.admin.web.PageResp;
import com.admin.web.request.LogPageReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统操作日志
 */
@RequestMapping("/sys")
@Api(tags = "系统模块-系统操作日志管理")
@RestController
public class SysLogController {

    @Resource
    private LogService logService;

    @PostMapping("/logs")
    @ApiOperation(value = "分页查询系统操作日志接口")
    @LogAnnotation(title = "系统操作日志管理", action = "分页查询系统操作日志")
    @SaCheckPermission("sys:log:list")
    public PageResp<SysLog> pageInfo(@RequestBody LogPageReq logPageReq) {
        return logService.page(logPageReq);
    }

    @DeleteMapping("/logs")
    @ApiOperation(value = "删除日志接口")
    @LogAnnotation(title = "系统操作日志管理", action = "删除系统操作日志")
    @SaCheckPermission("sys:log:deleted")
    public void deleted(@RequestBody List<String> logIds) {
        logService.deleteByIds(logIds);
    }

}
